home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / ProcDoggie 1.0a6 / UProcessGuts.p < prev    next >
Encoding:
Text File  |  1991-02-07  |  13.9 KB  |  357 lines  |  [TEXT/MPS ]

  1. UNIT UProcessGuts;
  2.  
  3. {-------------------------------------------------------------------------------
  4. #
  5. #    Apple Macintosh Developer Technical Support
  6. #
  7. #    Interfaces for the guts of the ProcDoggie application
  8. #
  9. #    Program:    ProcDoggie
  10. #    File:        UProcessGuts.p - Pascal Implementation
  11. #
  12. #    by:        Forrest Tanaka
  13. #
  14. #    Copyright © 1988-1991 Apple Computer, Inc.
  15. #    All rights reserved.
  16. #
  17. --------------------------------------------------------------------------------
  18. #
  19. #    Process Manager-related code that’s specific to ProcDoggie is contained in
  20. #    this unit.  Mainly, this code handles the user interface aspects of this
  21. #    program that relate to the Process Manager, such as the Process List window,
  22. #    the Process Information windows, and most of the menus.
  23. #
  24. #    The Process List window displays a list of all active processes.  It allows
  25. #    the user to click on one or more of the process names and then use menu
  26. #    commands to operate on those selected processes.
  27. #
  28. #    Process Information windows display information about the selected active
  29. #    processes.  The information includes the process’s name, type, creator, SIZE
  30. #    resource flags, partition size, and free memory availability.
  31. #
  32. #    When the user chooses to launch an application, routines in this unit are
  33. #    called to ask the user what process to launch and optionally what documents
  34. #    to open or print, depending on the current launch mode.
  35. #
  36. #    This unit also maintains the current launch mode.  The launch mode indicates
  37. #    whether the user wants to simply launch an application, launch an application
  38. #    along with documents to open, and launch an application with documents to
  39. #    print.  The launch mode is global for this application, and affects the way
  40. #    the menu commands that launch applications work.
  41. #
  42. -------------------------------------------------------------------------------}
  43. {[j=20/57/1$] Pasmat Options}
  44.  
  45.  
  46. INTERFACE
  47.  
  48.  
  49. (*******************************************************************************
  50. * Units
  51. *******************************************************************************)
  52.  
  53.     USES
  54.         (* Group 1 *)
  55.          Types
  56.         ,QuickDraw
  57.  
  58.         (* Group 2 *)
  59.         ,AppleEvents
  60.         ,Controls
  61.         ,Errors
  62.         ,Events
  63.         ,GestaltEqu
  64.         ,Memory
  65.         ,Menus
  66.         ,OSUtils
  67.         ,Resources
  68.         ,SegLoad
  69.         ,SysEqu
  70.         ,ToolUtils
  71.  
  72.         (* Group 3 *)
  73.         ,Aliases
  74.         ,Files
  75.         ,Lists
  76.         ,Processes
  77.         ,Script
  78.         ,Windows
  79.  
  80.         (* Group 4 *)
  81.         ,Dialogs
  82.         ,Palettes
  83.         ,StandardFile
  84.  
  85.         (* Group 5 *)
  86.         ,Packages
  87.  
  88.         (* Application *)
  89.         ,UGlobals
  90.         ,UDialogUtils
  91.         ,UEmergMem
  92.         ,UProcessUtils
  93.         ,UMenuHandler
  94.         ,UProcessLDEF
  95.         ;
  96.  
  97.  
  98. (*******************************************************************************
  99. * SetLaunchMode - Set the launch mode
  100. *
  101. * This routine is called to set the launching mode to the mode specified by the
  102. * "newMode" parameter.  A launch mode of "kJustLaunch" simply launches an
  103. * application or desk accessory, "kOpenLaunch" launches an application with one
  104. * or more documents for the launched application to open, "kPrintLaunch"
  105. * launches an application with one or more documents for the launched
  106. * application to print.  The launch modes are declared in UProcessUtils.p.
  107. *******************************************************************************)
  108.  
  109.     PROCEDURE SetLaunchMode (newMode: LaunchModeCode);
  110.  
  111.  
  112. (*******************************************************************************
  113. * GetLaunchMode - Get the launch mode
  114. *
  115. * The current launch mode is returned.  For details about launching modes, see
  116. * the description of the SetLaunchMode routine.
  117. *******************************************************************************)
  118.  
  119.     FUNCTION GetLaunchMode: LaunchModeCode;
  120.  
  121.  
  122. (*******************************************************************************
  123. * IsProcessListWindow - Is a WindowPtr a pointer to a process list window?
  124. *
  125. * When I want to find out whether a window that I have a pointer to is a process
  126. * list window or not, I call this routine.  It returns TRUE if aWindow is a
  127. * pointer to a process list window, FALSE if it isn’t.  If aWindow is NIL, then
  128. * IsProcessListWindow returns FALSE.
  129. *******************************************************************************)
  130.  
  131.     FUNCTION IsProcessListWindow (aWindow: WindowPtr): Boolean;
  132.  
  133.  
  134. (*******************************************************************************
  135. * CreateProcessListWindow - Create a process list window
  136. *
  137. * This routine is called to create a new Process List window visible and
  138. * centered on the main screen.  A pointer to the window is returned.  If there
  139. * isn’t enough memory for the window, or if some other problem happened to make
  140. * it impossible to create the window, then CreateProcessListWindow puts up an
  141. * alert indicating this to the user, and then it returns NIL.
  142. *******************************************************************************)
  143.  
  144.     FUNCTION CreateProcessListWindow: WindowPtr;
  145.  
  146.  
  147. (*******************************************************************************
  148. * IdleProcessListWindow - Keep the process list window up to date
  149. *
  150. * IdleProcessListWindow updates the process list window specified by
  151. * processListWindow so that it reflects the status of the processes that are
  152. * currently open.  It’s called once per main event loop iteration.
  153. *******************************************************************************)
  154.  
  155.     PROCEDURE IdleProcessListWindow (processListWindow: WindowPtr);
  156.  
  157.  
  158. (*******************************************************************************
  159. * DrawProcessListWindow - Draw the contents of the process list window
  160. *
  161. * Whenever an update event is received for the process list window, the routine
  162. * is called to draw into the window.  Since the process list covers the entire
  163. * window, the only thing to be done is to call the List Manager to draw the
  164. * list.  processListWindow is a pointer to the process list window.
  165. *******************************************************************************)
  166.  
  167.     PROCEDURE DrawProcessListWindow (processListWindow: WindowPtr);
  168.  
  169.  
  170. (*******************************************************************************
  171. * ClickProcessListWindow - Handle a mouse click in the process list window
  172. *
  173. * When a mouse click is detected in the content region of the process list
  174. * window specified by processListWindow, this routine is called to handle it.
  175. * It allows the user to select a process or several processes in the list.  If
  176. * the user double-clicks on a process, then that process and any other selected
  177. * processes are brought to the front.
  178. *
  179. * clickEvent is the mouse-down event that was in the process list window.
  180. *******************************************************************************)
  181.  
  182.     PROCEDURE ClickProcessListWindow (processListWindow: WindowPtr;
  183.                                       clickEvent:        EventRecord);
  184.  
  185.  
  186. (*******************************************************************************
  187. * ActivateProcessListWindow - Handle an activate/deactivate event
  188. *
  189. * Whenever an activate or deactivate event is received for the process list
  190. * window specified by processListWindow, this routine is called to handle the
  191. * event.  If the event was an activate event, then becomingActive is TRUE.  If
  192. * the event was a deactivate event, then becomingActive is FALSE.
  193. *******************************************************************************)
  194.  
  195.     PROCEDURE ActivateProcessListWindow (processListWindow: WindowPtr;
  196.                                          becomingActive:    Boolean);
  197.  
  198.  
  199. (*******************************************************************************
  200. * FixProcessListMenus - Undim menu items for process list window
  201. *
  202. * Any menus that should be available when the process list window is in front
  203. * are undimmed if the current conditions are appropriate.
  204. *******************************************************************************)
  205.  
  206.     PROCEDURE FixProcessListMenus (processListWindow: WindowPtr);
  207.  
  208.  
  209. (*******************************************************************************
  210. * IsProcessInfoWindow - Is a WindowPtr a pointer to a process info window?
  211. *
  212. * When I want to find out whether a window that I have a pointer to is a process
  213. * info window or not, I call this routine.  It returns TRUE if aWindow is a
  214. * pointer to a process info window, FALSE if it isn’t.  If aWindow is NIL, then
  215. * IsProcessInfoWindow returns NIL.
  216. *******************************************************************************)
  217.  
  218.     FUNCTION IsProcessInfoWindow (aWindow: WindowPtr): Boolean;
  219.  
  220.  
  221. (*******************************************************************************
  222. * IdleProcessInfoWindow - Give the specified process info window some idle time
  223. *
  224. * This routine is called once per event loop iteration.  It gives the specified
  225. * process info window some idle time to update the memory indicator.
  226. *******************************************************************************)
  227.  
  228.     PROCEDURE IdleProcessInfoWindow (processInfoWindow: WindowPtr);
  229.  
  230.  
  231. (*******************************************************************************
  232. * DrawProcessInfoWindow - Draw the contents of the process info window
  233. *
  234. * Whenever an update event is received for the process info window, the routine
  235. * is called to draw the static items into the window.
  236. *******************************************************************************)
  237.  
  238.     PROCEDURE DrawProcessInfoWindow (processInfoWindow: WindowPtr);
  239.  
  240.  
  241. (*******************************************************************************
  242. * FixProcessInfoMenus - Undim menu items for process information window
  243. *
  244. * Any menus that should be available when a process information window is in
  245. * front are undimmed if the current conditions are appropriate.
  246. *******************************************************************************)
  247.  
  248.     PROCEDURE FixProcessInfoMenus (processInfoWindow: WindowPtr);
  249.  
  250.  
  251. (*******************************************************************************
  252. * CloseProcessInfoWindow - Close a process info window
  253. *
  254. * The process info window specified by "processInfoWindow" is closed and all its
  255. * associated memory is deallocated.
  256. *******************************************************************************)
  257.  
  258.     PROCEDURE CloseProcessInfoWindow (processInfoWindow: WindowPtr);
  259.  
  260.  
  261. (*******************************************************************************
  262. * IdleAllProcessWindows - Give every open process window idle time
  263. *
  264. * IdleAllProcessWindows is called to give the process list window and all open
  265. * process info windows some idle time.  This routine is called once per main
  266. * event loop iteration.
  267. *******************************************************************************)
  268.  
  269.     PROCEDURE IdleAllProcessWindows;
  270.  
  271.  
  272. (*******************************************************************************
  273. * DoLaunchInFront - Launch a process to the front
  274. *
  275. * When the user wants to launch a process and have it brought to the front, this
  276. * routine is called.  It allows the user to choose a process through Standard
  277. * File.  That application is then launched and brought to the front.
  278. *******************************************************************************)
  279.  
  280.     PROCEDURE DoLaunchInFront;
  281.  
  282.  
  283. (*******************************************************************************
  284. * DoLaunchInBack - Launch a process to the back
  285. *
  286. * When the user wants to launch a process and have it sent to the back of all of
  287. * the open processes, this routine is called.  It allows the user to choose a
  288. * process through Standard File.  That process is then launched and sent to the
  289. * back.
  290. *******************************************************************************)
  291.  
  292.     PROCEDURE DoLaunchInBack;
  293.  
  294.  
  295. (*******************************************************************************
  296. * DoLaunchTo - Launch a process and terminate self
  297. *
  298. * When the user wants to launch a process and then immediately quit ProcDoggie,
  299. * this routine is called.  It allows the user to choose a process through
  300. * Standard File.  That process is then launched and brought to the front, and
  301. * then ProcDoggie is immediately terminated.
  302. *******************************************************************************)
  303.  
  304.     PROCEDURE DoLaunchTo;
  305.  
  306.  
  307. (*******************************************************************************
  308. * DoLaunchMode - Handle Simple Launch, Open on Launch, Print on Launch commands
  309. *
  310. * This routine is called when a launch mode menu item is chosen.  The launch
  311. * mode items are in the file menu and are the “Simple Launch,” “Open Documents
  312. * on Launch,” and “Print Documents on Launch” items.
  313. *******************************************************************************)
  314.  
  315.     PROCEDURE DoLaunchMode (modeItem: Integer);
  316.  
  317.  
  318. (*******************************************************************************
  319. * DoBringProcessToFront - Bring an open process to the front
  320. *
  321. * When the user chooses the Bring to Front menu item, this routine is called to
  322. * bring all the selected process to the front in the order that they appear in
  323. * the process list window specified by processListWindow.  For the moment, it
  324. * won’t bring it’s own application (ProcDoggie) to the front.  I don’t know how
  325. * or whether I’ll be able to fix that.
  326. *******************************************************************************)
  327.  
  328.     PROCEDURE DoBringProcessToFront (processListWindow: WindowPtr);
  329.  
  330.  
  331. (*******************************************************************************
  332. * DoGetProcessInfo - Get information about selected processes
  333. *
  334. * This routine is called when the user desires information about the processes
  335. * selected in the process list window specified by the "processListWindow"
  336. * parameter.
  337. *******************************************************************************)
  338.  
  339.     PROCEDURE DoGetProcessInfo (processListWindow: WindowPtr);
  340.  
  341.  
  342. (*******************************************************************************
  343. * DoTerminateProcess - Terminate the selected processes
  344. *
  345. * This routine is called when the user wants to terminate the processes selected
  346. * in the process list window specified by the "processListWindow" parameter.
  347. *******************************************************************************)
  348.  
  349.     PROCEDURE DoTerminateProcess (processListWindow: WindowPtr);
  350.  
  351.  
  352. IMPLEMENTATION
  353.  
  354.     {$I UProcessGuts.inc1.p}
  355.  
  356. END.
  357.